<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        <meta name="layout" content="main" />
        <title>iPET - Integrantes</title>
    </head>
    <body>
    	<g:render template="/common/menuUser" />
    	<div id="text">
        <div class="body">
            <g:if test="${flash.message}">
            <div class="message">${flash.message}</div>
            </g:if>
            <h2>Tutor</h2>
            <div class="list">
                <table>
                    <thead>
                        <tr>
                            <th class="leftth actions">Ações</th>
                            <g:sortableColumn property="nome" title="${message(code: 'user.nome.label', default: 'Nome completo')}" />
                            <g:sortableColumn class="rightth" property="email" title="${message(code: 'user.email.label', default: 'E-mail')}" />
                        </tr>
                    </thead>
                    <tbody>
	                   <tr class="odd">
	                       <td>
	                       	<div class="actions">
	                        	<g:link action="show" controller="tutor" id="${tutorInstance.id}" title="Visualizar"><img alt="Edit" src="${resource(dir:'images/icons',file:'view.png')}" /></g:link>
					            <g:if test="${session.user.isAdmin || session.user.login == tutorInstance.login}">
						            <g:link action="edit" controller="tutor" id="${tutorInstance.id}" title="Editar"><img alt="Edit" src="${resource(dir:'images/icons',file:'edit.png')}" /></g:link>
						            <g:link action="delete" controller="tutor" id="${tutorInstance.id}" title="Excluir" onclick="if (confirm('Esta ação não pode ser desfeita, tem certeza?')) { var f = document.createElement('form'); f.style.display = 'none'; this.parentNode.appendChild(f); f.method = 'POST'; f.action = this.href; f.submit(); };return false;"><img alt="Delete" src="${resource(dir:'images/icons',file:'trash.png')}" /></g:link>
					            </g:if>
	                       	</div>
	                       </td>
	                       <td>${fieldValue(bean: tutorInstance, field: "nome")} ${fieldValue(bean: tutorInstance, field: "sobrenome")}</td>
	                       <td>${fieldValue(bean: tutorInstance, field: "email")}</td>
	                   </tr>
                    </tbody>
				</table>
			</div>

            <h2>Petianos</h2>
            <g:if test="${usuarioInstanceList}">
	            <div class="list">
	                <table>
	                    <thead>
	                        <tr>
	                            <th class="leftth actions">Ações</th>
	                            <g:sortableColumn property="nome" title="${message(code: 'user.nome.label', default: 'Nome completo')}" />
	                            <g:sortableColumn class="rightth" property="email" title="${message(code: 'user.email.label', default: 'E-mail')}" />
	                        </tr>
	                    </thead>
	                    <tbody>
	                    <g:each in="${usuarioInstanceList}" status="i" var="usuarioInstance">
	                        <tr class="${(i % 2) == 0 ? 'odd' : 'even'}">
	                            <td>
	                            	<div class="actions">
		                            	<g:link action="show" controller="petiano" id="${usuarioInstance.id}" title="Visualizar"><img alt="Edit" src="${resource(dir:'images/icons',file:'view.png')}" /></g:link>
							            <g:if test="${session.user.isAdmin || session.user.login == usuarioInstance.login}">
								            <g:link action="edit" controller="petiano" id="${usuarioInstance.id}" title="Editar"><img alt="Edit" src="${resource(dir:'images/icons',file:'edit.png')}" /></g:link>
								            <g:link action="delete" controller="petiano" id="${usuarioInstance.id}" title="Excluir" onclick="if (confirm('Esta ação não pode ser desfeita, tem certeza?')) { var f = document.createElement('form'); f.style.display = 'none'; this.parentNode.appendChild(f); f.method = 'POST'; f.action = this.href; f.submit(); };return false;"><img alt="Delete" src="${resource(dir:'images/icons',file:'trash.png')}" /></g:link>
							            </g:if>
	                            	</div>
	                            </td>
	                            <td>${fieldValue(bean: usuarioInstance, field: "nome")} ${fieldValue(bean: usuarioInstance, field: "sobrenome")}</td>
	                            <td>${fieldValue(bean: usuarioInstance, field: "email")}</td>
	                        </tr>
	                    </g:each>
	                    </tbody>
					</table>
				</div>
			</g:if>
			<g:else>
				<div class="dialog createBlank">
					<h1><g:link action="create" controller="petiano">Cadastre o primeiro petiano</g:link></h1>
					<p>Quando cadastrado um petiano, será listado um resumo de informações sobre o mesmo.</p>
				</div>
			</g:else>
        </div>
        </div>
    </body>
</html>
